import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {Observable} from "rxjs";
import {Borrow} from '../../shared/model/borrow.interface'
import {BorrowList} from '../../shared/model/borrowList.interface'


@Injectable({
  providedIn: 'root'
})
export class BorrowApiService{
  constructor(private readonly httpClient: HttpClient) {
  }
  creat(borrow: Borrow): Observable<void>{
    return this.httpClient.post<void>('/borrows',borrow);
  }
  count(): Observable<any> {
    return this.httpClient.get('/borrows/count');
  }
  getAll(BorrowUserId:string): Observable<BorrowList[]> {
    return this.httpClient.get<BorrowList[]>(`/borrows/${BorrowUserId}`);
  }
  delete(BorrowId: number): Observable<null> {
    return this.httpClient.delete<null>(`/borrows/${BorrowId}`);
  }
}
